#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>
#include<stdbool.h>
#include<string.h>
#include<ctype.h>

bool judge(char* arr, int n)
{
    int flag_num = 0;
    int flag_lower = 0;
    int flag_upper = 0;
    if (n < 8)
        return false;
    if (arr[0] >= '0' && arr[0] <= '9')
        return false;
    for (int i = 0; i < n; i++)
    {
        if (!flag_num && isdigit(arr[i]))
            flag_num = 1;
        if (!flag_lower && islower(arr[i]))
            flag_lower = 1;
        if (!flag_upper && isupper(arr[i]))
            flag_upper = 1;
        if (!isalnum(arr[i]))
            return false;
    }
    if (flag_lower + flag_num + flag_upper < 2)
        return false;
    return true;
}
int main() 
{
    int n = 0;
    char str[101] = { 0 };
    scanf("%d", &n);
    for (int i = 0; i < n; ++i)
    {
        scanf("%s", str);
        if (judge(str, strlen(str)))
            printf("YES\n");
        else
            printf("NO\n");
    }
    return 0;
}

int GetNumberOfK(int* data, int dataLen, int k)
{
    int left = 0;
    int right = dataLen - 1;
    int time = 0;
    while (left <= right)
    {
        int mid = (left + right) / 2;
        if (data[mid] > k)
            right = mid - 1;
        else if (data[mid] < k)
            left = mid + 1;
        else
        {
            for (; right >= mid; --right)
                if (data[right] == k)
                    ++time;
        }
    }
    return time;
}

int convertInteger(int A, int B)
{
    unsigned int i = A ^ B;
    int num = 0;
    while (i)
    {
        i &= (i - 1);
        ++num;
    }
    return num;
}